import subprocess


def configure_wifi(ip, subnet_mask, gateway, dns):
    # 配置IP地址
    subprocess.run(f'netsh interface ip set address name="WLAN" static {ip} {subnet_mask} {gateway} 1', shell=True)

    # 配置DNS服务器
    subprocess.run(f'netsh interface ip set dns name="WLAN" static {dns}', shell=True)

    print("WLAN网卡配置成功！")


def test():
    pass


def reset_network_settings():
    # 使用netsh命令来重置网络设置
    # 设置WLAN网卡为自动获取IP地址
    subprocess.run(['netsh', 'interface', 'ipv4', 'set', 'address', 'name="Wi-Fi"', 'source=dhcp'])

    # 设置WLAN网卡为自动获取DNS服务器地址
    subprocess.run(['netsh', 'interface', 'ipv4', 'set', 'dns', 'name="Wi-Fi"', 'source=dhcp'])

    print("网络设置已恢复为默认值！")


# 示例：将WLAN网卡配置为静态IP和DNS
# configure_wifi('192.168.1.100', '255.255.255.0', '192.168.1.1', '8.8.8.8')
# reset_network_settings()
